package sz.szsmk.citizencard.ui.adapter;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.model.network.bean.response.QueryInvoiceOpensRes;
import sz.szsmk.citizencard.util.Constant;
import sz.szsmk.citizencard.util.JumpUtils;

/**
 * author: hyt
 * created on:
 * description:
 */
public class Card_Ticket_Adapter extends BaseQuickAdapter<QueryInvoiceOpensRes.DetailsEntity, BaseViewHolder>  {


    public Card_Ticket_Adapter() {
        super(R.layout.item_card_ticket);
    }

    @Override
    protected void convert(BaseViewHolder helper, QueryInvoiceOpensRes.DetailsEntity item) {
        helper.setText(R.id.tv_money,item.getMoney());
        helper.setText(R.id.tv_time,item.getTime());

        helper.itemView.findViewById(R.id.tv_copyUrl).setOnClickListener(v->{
            // 获取系统剪贴板
            ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
            // 创建一个剪贴数据集，包含一个普通文本数据条目（需要复制的数据）
            ClipData clipData = ClipData.newPlainText(null,  item.getFtp());
            // 把数据集设置（复制）到剪贴板
            clipboard.setPrimaryClip(clipData);
            Toast.makeText(mContext, "复制成功", Toast.LENGTH_SHORT).show();
        });
        helper.itemView.findViewById(R.id.tv_down).setOnClickListener(v->{
            Bundle bundle = new Bundle();
            bundle.putString("url", item.getFtp());
            JumpUtils.jumptoNatvie(mContext, "webView", 0, bundle);

        });
    }
}
